#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<sys/wait.h>

int main(){
    char buff[1024];
    int pid ;
    int pfd[2];
    int res = pipe(pfd);
    int status = 0;
    if(res == -1){
        perror("pipe");
        exit(1);
    }

    close(pfd[0]);
    pid = fork();
    if(pid == -1){
        perror("fork");
        exit(1);
    }

    if(pid == 0){
        write(pfd[1],buff, 1024);
    }

    if(pid > 0){
        wait(&status);
        printf("child exit status is %d\n", status);
    }
    return 0;
}